{% extends 'app/base.html' %}
{% load i18n %}
{% load staticfiles %}

{% block head-title %}{% if current_category %}{{ current_category.name }} - {% elif is_featured_category %}{% trans 'Featured apps - ' %}{% else %}{% trans 'All apps' %} - {% endif %}{% endblock %}
{% block head %}
    <script defer src="{% static 'public/app/list.js' %}" type="text/javascript"></script>
{% endblock %}

{% block apps %}


<div class="row">
    <ul class="nav-tabs nav sorting">
        <li role="presentation" class="{% if not request.GET.order_by or request.GET.order_by == 'rating_overall' %}active{% endif %}"><a href="{{ request.url }}?order_by=rating_overall&amp;ordering=desc{% if url_params.search_filters %}&amp;{{ url_params.search_filters }}{% endif %}">{% trans 'Rating' %}</a></li>
        <li role="presentation" class="{% if request.GET.order_by == 'rating_recent' %}active{% endif %}"><a href="{{ request.url }}?order_by=rating_recent&amp;ordering=desc{% if url_params.search_filters %}&amp;{{ url_params.search_filters }}{% endif %}">{% trans 'Rating (recent)' %}</a></li>
        <li role="presentation" class="{% if request.GET.order_by == 'last_release' %}active{% endif %}"><a href="{{ request.url }}?order_by=last_release&amp;ordering=desc{% if url_params.search_filters %}&amp;{{ url_params.search_filters }}{% endif %}">{% trans 'Latest' %}</a></li>
        {% if request.GET.order_by == 'name' and request.GET.ordering == 'asc' %}
            <li role="presentation" class="{% if request.GET.order_by == 'name' %}active{% endif %}"><a href="{{ request.url }}?order_by=name&amp;ordering=desc{% if url_params.search_filters %}&amp;{{ url_params.search_filters }}{% endif %}"><span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span> {% trans 'Alphabetical' %}</a></li>
        {% elif request.GET.order_by == 'name' and request.GET.ordering == 'desc' %}
            <li role="presentation" class="{% if request.GET.order_by == 'name' %}active{% endif %}"><a href="{{ request.url }}?order_by=name&amp;ordering=asc{% if url_params.search_filters %}&amp;{{ url_params.search_filters }}{% endif %}"><span class="glyphicon glyphicon-triangle-top" aria-hidden="true"></span> {% trans 'Alphabetical' %}</a></li>
        {% else %}
            <li role="presentation" class="{% if request.GET.order_by == 'name' %}active{% endif %}"><a href="{{ request.url }}?order_by=name&amp;ordering=asc{% if url_params.search_filters %}&amp;{{ url_params.search_filters }}{% endif %}"><span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span> {% trans 'Alphabetical' %}</a></li>
        {% endif %}
        <li role="presentation" class="filters">
            <form method="get" action="{{ request.path }}" name="filter-form" id="filter-form">
                {% if not is_featured_category %}
                <input type="checkbox" class="auto-submit" id="featured-checkbox" name="is_featured" value="true" {% if request.GET.is_featured == 'true' %}checked{% endif %}>
                <label for="featured-checkbox">{% trans 'Featured' %}</label>
                {% endif %}
                {% if request.user.is_authenticated %}
                    <input type="checkbox" class="auto-submit" id="myapps-checkbox" name="maintainer" value="{{ request.user.username }}" {% if request.GET.maintainer == request.user.username %}checked{% endif %}>
                    <label for="myapps-checkbox">{% trans 'My apps' %}</label>
                {% endif %}

                {# Include all GET arguments that should be preserved when applying a filter. #}
                {% if request.GET.search %}<input type="hidden" name="search" value="{{ request.GET.search }}">{% endif %}
                {% if request.GET.order_by %}<input type="hidden" name="order_by" value="{{ request.GET.order_by }}">{% endif %}
                {% if request.GET.ordering %}<input type="hidden" name="ordering" value="{{ request.GET.ordering }}">{% endif %}
            </form>
        </li>
    </ul>
</div>
{% for app in object_list %}
        <div class="col-md-6 app-list-container">
            <div class="well">
                <div class="app-list-screenshot center">
                {% if app.screenshots.all %}
                    <a href="{% url 'app-detail' id=app.id %}" ><img class="b-lazy" src="{% static 'assets/img/loading.gif' %}" data-src="{{ app.screenshots.all.0.front_img_small }}" alt="{% trans 'Screenshot' %}"></a>
                {% else %}
                    <a href="{% url 'app-detail' id=app.id %}" ><img class="b-lazy default-screenshot" src="{% static 'assets/img/loading.gif' %}" data-src="{% static 'assets/img/no-screenshot.svg' %}" alt="{% trans 'Screenshot' %}"></a>
                {% endif %}
                </div>
                <h3><a title="{{ app.name }}" href="{% url 'app-detail' id=app.id %}">{{ app.name }}</a></h3>
                <p title="{{ app.summary }}">{{ app.summary }}</p>
            </div>
        </div>
{% empty %}
    <div class="col-lg-6 app-list-container">
        {% if search_query and current_category %}
            <p class="message no-apps-found">{% blocktrans with category=current_category.name query=search_query %}No apps found for search "<em>{{ query }}</em>" in {{ category }}.{% endblocktrans %}</p>
        {% elif search_query %}
            <p class="message no-apps-found">{% blocktrans with query=search_query %}No apps found for search "<em>{{ query }}</em>".{% endblocktrans %}</p>
        {% endif %}
    </div>
{% endfor %}

{% endblock %}

